package com.todoit.wavebot.util;

import java.util.ArrayList;
import javax.jdo.annotations.PersistenceCapable;
import com.google.wave.api.Gadget;

// have to extend a concrete list type.
// there should be a nice OO construct to allow picking the list
// but hey, screw that for now.

@PersistenceCapable
public class TodoitTaskList extends ArrayList<TodoitTask>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	// ToCSV - add headers and call toCSV on each and every list item
	public String toCSV()
	{
		String retval = "\"id\"," +
			"\"title\"," +
			"\"priority\"," +
			"\"dueDate\"," +
			"\"location\"," +
			"\"tags\"," +
			"\"link\"," +
			"\"progress\"," +
			"\"status\"," +
			"\"creator\"," +
			"\"owner\"," +
			"\"lastModifier\"," +
			"\"lastmodified\"," +
			"\"completedDate\"," +
			"\"completer\"," +
			"\"addedDate\"," +
			"\"freq\"," +
			"\"dur\"" +
			"\n";
		for (TodoitTask t : this)
		{
			retval = retval + t.toCSV() + "\n";
		};
		return retval;
	};
	// default constructor to return a default list
	public TodoitTaskList()
	{
		// create sample task 1
		TodoitTask t;
		t = new TodoitTask(1);
		this.add(t);
		// create sample task 2		
		t = new TodoitTask(2);
		this.add(t);
	}
	// fromCSV - parse headers and fill each item from CSV
	public TodoitTaskList(String CSV)
	{
		// ignore first line
		// for (line : lines)
		// 	task.next = new task(line);
		// 
	}
	// fromGadget - missing due to lack of integration
	public TodoitTaskList(Gadget g)
	{
	
	}

	// toGadget - ?

}
